package com.example.concurrent;

import java.util.concurrent.Future;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author houyangfan
 * @version 1.0
 * @date 2022/10/2 16:07
 */
public class TestGetThread {

    public static void main(String[] args) {

        Lock lock = new ReentrantLock();
        Phone phone = new Phone();
        new Thread(()->{
            phone.call();
        }).start();
        new Thread(()->{
            phone.sms();
        }).start();
    }
}

class Phone{

    public synchronized void sms(){
        System.out.println("发短信");
    }

    public synchronized void call(){
        System.out.println("打电话");
    }
}
